<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<style>
.theme_list {
	overflow: hidden;
	padding-top: 15px;
}

.theme_list li {
	border: 1px #DDD solid;
	width: 320px;
	float: left;
	margin-left: 15px;
	margin-bottom: 10px;
}

.theme_list li .theme_pic {
	display: block;
	width: 320px;
	height: 160px;
	overflow: hidden;
}

.theme_list li .theme_pic img {
	width: 320px;
}

.theme_list li .theme_main {
	padding: 10px;
	overflow: hidden;
}

.theme_list li .theme_main .theme_title {
	font-size: 16px;
	height: 20px;
	width: 217px;
	overflow: hidden;
}

.theme_list li .theme_main .pull-left {
	color: #999;
}
</style>
<ul class="nav nav-tabs">
	<li><a href="javascript:history.go(-1);">返回</a></li>
	<li <?php  if($operation== 'post') { ?>class="active"<?php  } ?>><a
		href="<?php  echo $this->createWebUrl('giftgroupset', array('op' => 'post'));?>">添加分组</a></li>
	<li <?php  if($operation== 'display') { ?>class="active"<?php  } ?>><a
		href="<?php  echo $this->createWebUrl('giftgroupset', array('op' => 'display'));?>">管理分组</a></li>
	<?php  if($operation == 'gifts') { ?><li class="active"><a href="<?php  echo $this->createWebUrl('giftgroupset', array('op' => 'gifts'));?>">管理奖品</a></li><?php  } ?>
</ul>
<?php  if($operation == 'post') { ?>
<div class="main">
	<form action="" method="post" onsubmit="return check(this)"
		class="form-horizontal form" enctype="multipart/form-data">
		<input type="hidden" name="giftgroupid" value="<?php  echo $giftgroup['id'];?>" />
  <div class="panel panel-default">
    <div class="panel-heading">
        分组名称编辑
    </div>
    <div class="panel-body">
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">奖品分组名称</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" id="groupname" name="groupname" class="form-control" value="<?php  echo $giftgroup['groupname'];?>" placeholder="分组名称" />
            </div>
        </div>
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">所属主题</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" id="themename" name="themename" class="form-control" readonly="readonly" value="<?php  echo $giftgroup['themename'];?>"  />
            </div>
        </div>
    </div>
</div>
		<div class="form-group">
			<div class="col-sm-12">
			<input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1"> 
			<input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />	
			</div>
       </div>
		
	</form>
</div>

<script type="text/javascript">
	function check(form) {

		if (!form['groupname'].value) {
			$("input[name='groupname']").focus();
			alert('主人，起一个高大上的奖品分组名称吧！');
			return false;
		}
		return true;
	}
</script>

<?php  } else if($operation == 'display') { ?>
<div class="main">
	<div style="padding: 15px;">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="min-width: 100px; max-width: 300px;">分组名称</th>
					<th style="min-width: 100px; max-width: 300px;">所属主题</th>
					<th style="min-width: 100px; max-width: 300px;">常用操作</th>
					<th style="text-align: right; min-width: 60px;">操作</th>
				</tr>
			</thead>
			<tbody>
				<?php  if(is_array($list)) { foreach($list as $item) { ?>
				<tr>
					<td style="max-width: 10px;"><?php  echo $item['groupname'];?></td>
					<td style="min-width: 200px; max-width: 300px;"><?php  echo $item['themename'];?></td>
					<td style="min-width: 200px; max-width: 300px;">
					<a href="<?php  echo $this->createWebUrl('giftgroupset', array('op' => 'gifts','giftgroupid' => $item['id']));?>">奖品管理</a></td>
					<td style="text-align: right; min-width: 60px;"><a
						href="<?php  echo $this->createWebUrl('giftgroupset', array('op' => 'post','giftgroupid' => $item['id']));?>"
						title="编辑" class="btn btn-default"><i class="fa fa-edit"></i></a> <a
						href="<?php  echo $this->CreateWebUrl('giftgroupset', array('op' => 'delete','giftgroupid' => $item['id']));?>"
						onclick="return confirm('此操作将连同分组下的奖品都删除，确认删除？');return false;" title="删除"
						class="btn btn-default"><i class="fa fa-times"></i></a></td>
				</tr>
				<?php  } } ?>
			</tbody>
		</table>
	</div>
</div>
<?php  } else if($operation == 'gifts') { ?>
<style>
.gift_list{padding:15px 0;}
.gift_list .alert{width:auto; margin-top:10px; overflow:hidden;}
.gift_list table{margin-left:40px;}
.gift_list table th,.gift_list table td{padding-bottom:5px;}
.gift_list table th{width:60px; font-size:14px;}
.gift_list table input,.gift_list table select{margin-bottom:0;}
</style>
<div class="main">
	<div class="gift_list">
	<form method="post" class="form" action="<?php  echo $this->CreateWebUrl('batchgift');?>">
	<input name="token" type="hidden" value="<?php  echo $_W['token'];?>" />
	<input name="groupid" type="hidden" value="<?php  echo $giftgroupid;?>" />
	<input type="submit" name="submit" id="selectimage" class="btn" value="保存奖品信息" />
	<?php  if(is_array($gifts)) { foreach($gifts as $gift) { ?>
	<div class="alert alert-block alert-new">
		<input type="hidden" value="<?php  echo $gift['id'];?>" name="giftarray[<?php  echo $gift['id'];?>]">
      <div class="panel-body">
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" class="form-control" value="<?php  echo $gift['sort'];?>" name="sort[<?php  echo $gift['id'];?>]">
            </div>
        </div>
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">奖品名称</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" class="form-control" value="<?php  echo $gift['stdname'];?>" name="stdname[<?php  echo $gift['id'];?>]">
            </div>
        </div>
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">所属分组</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" readonly="readonly" class="form-control" value="<?php  echo $gift['groupname'];?>" name="groupname[<?php  echo $gift['id'];?>]">
            </div>
        </div>
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">奖品单位</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" class="form-control" value="<?php  echo $gift['unit'];?>" name="unit[<?php  echo $gift['id'];?>]">
            </div>
        </div>
		
		
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">所需积分</label>
            <div class="col-sm-9 col-xs-12">
			   <input type="text" class="form-control" value="<?php  echo $gift['needscore'];?>" name="needscore[<?php  echo $gift['id'];?>]">
            </div>
			
        </div>
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">奖品数量</label>
            <div class="col-sm-9 col-xs-12">
                 <input type="text" class="form-control" value="<?php  echo $gift['amount'];?>" name="amount[<?php  echo $gift['id'];?>]">
            </div>
        </div>
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">剩余数量</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" class="form-control" value="<?php  echo $gift['left'];?>" name="left[<?php  echo $gift['id'];?>]">
            </div>
        </div>
		<div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">奖品描述</label>
            <div class="col-sm-9 col-xs-12">
               	<input type="text" class="form-control" value="<?php  echo $gift['desc'];?>" name="desc[<?php  echo $gift['id'];?>]">
            </div>
        </div>
      
    </div>
</div>

	

	</div>
	<?php  } } ?>
	</form>
	</div>
</div>
<?php  } ?> <?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>
